package Utils.Concurrent;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;

import Utils.UI.UIUpdater;

public class LoaderRunner extends AsyncTask<Object> {

	public LoaderRunner(Display display, Object... vals) {
		super(display, vals);
	}

	@Override
	public String doInBackground() {
		Label loadingLabel = (Label) vals[0];
		String loadingText = (String) vals[1];
		try {
			while (true) {

				UIUpdater.setWidgetText(loadingLabel, loadingText);
				Thread.sleep(210);
				UIUpdater
						.setWidgetText(loadingLabel, loadingText + ".");
				Thread.sleep(210);
				UIUpdater.setWidgetText(loadingLabel, loadingText
						+ "..");
				Thread.sleep(210);
				UIUpdater.setWidgetText(loadingLabel, loadingText
						+ "...");
				Thread.sleep(210);

			}
		} catch (Exception e) {
			// System.out.println("LoaderRunner interrupted");
		}
		return null;

	}

	@Override
	public void onInterrupt() {
		// TODO Auto-generated method stub
		
	}

}